export default class Event {
  add(key,fn) {
    if(!this[key]){
      this[key] = [];
    }
    this[key].push(fn);
  }
  remove(key,fn){
    if(this[key]){
      let index = this[key].indexOf(fn)
      this[key].splice(index,1);
    }
  }
  trigger(key,_this){
    if(this[key]){
      this[key].forEach(fn=>{
        fn.apply(_this,Array.from(arguments).slice(2));
      })
    }
  }
}